package com.meichis.yndms.vm;

import androidx.lifecycle.MutableLiveData;

import com.meichis.mcsappframework.utils.DateUtil;
import com.meichis.yndms.model.StayInOrder;
import com.meichis.yndms.repository.manager.StayInOrderManager;

import java.util.List;

/**
 * @author xmy
 * @title
 * @remake
 * @create 2022-05-17 16:23
 */
public class StayInOrderVM extends MyViewModel {

    //接口请求的所有数据
    private MutableLiveData<List<StayInOrder>> allDatas;

    private MutableLiveData<String> BeginTime;
    private MutableLiveData<String> EndTime;


    public MutableLiveData<String> getBeginTime() {
        if (BeginTime == null) {
            BeginTime = new MutableLiveData<>();
            BeginTime.setValue(DateUtil.getMultipleDay(DateUtil.getCurDateStr(DateUtil.FORMAT_YMD), -7));
        }

        return BeginTime;
    }

    public MutableLiveData<String> getEndTime() {
        if (EndTime == null) {
            EndTime = new MutableLiveData<>();
            EndTime.setValue(DateUtil.getMultipleDay(DateUtil.getCurDateStr(DateUtil.FORMAT_YMD), 7));
        }
        return EndTime;
    }


    public MutableLiveData<List<StayInOrder>> getAllDatas() {
        if (allDatas == null) {
            allDatas = new MutableLiveData<>();
        }
        return allDatas;
    }


    public void getPartnerStayIn( String startDtStr, String endDtStr) {
        StayInOrderManager.getInstance().getPartnerStayIn(getShowDialog(),
                getUserInfo().getValue().getOrgId(), startDtStr, endDtStr, getAllDatas());
    }
}
